package g_format;

import java.text.ChoiceFormat;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.xml.soap.MessageFactory;

public class Format {
	public Format(){
		stringFormat();
		decimalFormat();
		simpleDateFormat();
		choiceFormat();
		messageFormat();
		
	}
	public void stringFormat(){
		String str = String.format("입금 : %-5d원", 1000);
		output(str);
		
		str = String.format("입금 : %-10.1f",1234567.89);
		output(str);

		str = String.format("문자 : %10c",'a');
		output(str);

		str = String.format("문자열 : %-10s","park w.g");
		output(str);
	}
	
	public void decimalFormat(){
		DecimalFormat df = new DecimalFormat("#,###.###");
		String str = df.format(1234667.89);
		output(str);
	}
	
	public void simpleDateFormat(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String str = sdf.format(new Date());
		output(str);
	}
	
	public void choiceFormat(){
		double limit[] ={60,70,80,90}; // 오름차순으로 정렬되어 있어야 함
		String grade[] = {"D","C","B", "A"};
		int myscore[] = {88,77,99,55,66,45,55,88,77,88};
		
		ChoiceFormat cf = new ChoiceFormat(limit, grade);
		for(int a : myscore){
			System.out.println(a + " : " +cf.format(a));
		}
	}
	
	public void messageFormat(){
		String str = " name : {0} \n age : {1} \n address : {2}";
		String args[] ={"hong","18", "남원"};
		String r = MessageFormat.format(str, args);
		output(r);
	}
	
	public void output(String str){
		System.out.println(str);
	}
	
	public static void main(String[] args) {
		new Format();

	}

}
